package com.augurit.smartform.display.gis;

import com.augurit.smartform.display.TagElement;
import com.augurit.smartform.display.TagParser;

public class MainPaneParser implements TagParser {

	public String[] parser(TagElement tagElement) {
		String[] strArr=new String[3];
		StringBuffer js=new StringBuffer();
		
		js.append("<style type=\"text/css\">");
		js.append(System.getProperty("line.separator"));
		js.append("@import \"${ctx}/2DMap/com/augurit/resources/themes/toolbar/css/main.css\";");
		js.append(System.getProperty("line.separator"));
		js.append("@import \"${ctx}/2DMap/com/augurit/resources/themes/label/main.css\";");
		js.append(System.getProperty("line.separator"));
		js.append("@import \"${ctx}/2DMap/com/augurit/resources/themes/style.css\";");
		js.append(System.getProperty("line.separator"));
		js.append("@import \"${ctx}/2DMap/com/augurit/resources/themes/infowindow/InfoWindow.css\";");
		js.append(System.getProperty("line.separator"));
		js.append("@import \"${ctx}/2DMap/com/augurit/resources/themes/scalebar.css\";");
		js.append(System.getProperty("line.separator"));
		js.append(".labelOnClick{background: #cfffff;}");
		js.append(System.getProperty("line.separator"));
		js.append("div{-moz-user-select : none}");
		js.append(System.getProperty("line.separator"));
		js.append("</style>");
		js.append(System.getProperty("line.separator"));
		
		js.append(System.getProperty("line.separator"));
		js.append("<script type=\"text/javascript\" src=\"${ctx}/2DMap/com/augurit/resources/dojo/dojo/dojo.js\"></script>");
		js.append(System.getProperty("line.separator"));
		js.append("<script type=\"text/javascript\" src=\"${ctx}/2DMap/com/augurit/gis/MicGis_single.js\"></script>");
		js.append(System.getProperty("line.separator"));
		js.append("<script type=\"text/javascript\" src=\"${ctx}/2DMap/com/augurit/gis/MicGis_control.js\"></script>");
		js.append(System.getProperty("line.separator"));
		
		js.append(System.getProperty("line.separator"));
		js.append("<script type=\"text/javascript\">");
		js.append(System.getProperty("line.separator"));
		js.append("dojo.require(\"AG.MicGIS.gis.MapInIt\");");
		js.append(System.getProperty("line.separator"));
		js.append("dojo.require(\"dojo.parser\");");
		js.append(System.getProperty("line.separator"));
		js.append("var baseUrl = '';");
		js.append(System.getProperty("line.separator"));
		js.append("</script>");
		js.append(System.getProperty("line.separator"));
		
		js.append(System.getProperty("line.separator"));
		js.append("<script type=\"text/javascript\">");
		js.append(System.getProperty("line.separator"));
		js.append("var GisObject = null;");
		js.append(System.getProperty("line.separator"));
		js.append("$(window).bind(\"load\", function(){");
		js.append(System.getProperty("line.separator"));
		js.append("initMap();");
		js.append(System.getProperty("line.separator"));
		js.append("try{");
		js.append(System.getProperty("line.separator"));
		js.append("if(typeof(eval(\""+tagElement.getId()+"_afterMapLoad\"))==\"function\"){"+tagElement.getId()+"_afterMapLoad();}");
		js.append(System.getProperty("line.separator"));
		js.append("}catch(e){}");
		js.append(System.getProperty("line.separator"));
		js.append("//GisObject.addZoomBar();");
		js.append(System.getProperty("line.separator"));
		js.append("//GisObject.addOMap();");
		js.append(System.getProperty("line.separator"));
		js.append("//GisObject.addScalebar();");
		js.append(System.getProperty("line.separator"));
		js.append("//GisObject.addToolPanel();");
		js.append(System.getProperty("line.separator"));
		js.append("});");
		js.append(System.getProperty("line.separator"));
		js.append(System.getProperty("line.separator"));
		js.append("function initMap(){");
		js.append(System.getProperty("line.separator"));
		js.append("GisObject = new AG.MicGIS.gis.MapInIt(\""+tagElement.getId()+"\");");
		js.append(System.getProperty("line.separator"));
		js.append("var mapParams = {");
		js.append(System.getProperty("line.separator"));
		js.append("resolutions : \"76.437066666666624,38.218533333333312,19.109266666666713,9.554633333333300,4.777316666666707\",");
		js.append(System.getProperty("line.separator"));
		js.append("extent: \"461339.4642,2155065.1479,554309.1111,2239097.1643\",");
		js.append(System.getProperty("line.separator"));
		js.append("center : \"502703.42000,2214050.18490\",");
		js.append(System.getProperty("line.separator"));
		js.append("zoom : 1");
		js.append(System.getProperty("line.separator"));
		js.append("}");
		js.append(System.getProperty("line.separator"));
		js.append("GisObject.setMapOptions(mapParams);");
		js.append(System.getProperty("line.separator"));
		js.append("addLayers(GisObject);");
		js.append(System.getProperty("line.separator"));
		js.append("var newCenter = new AG.MicGIS.LonLat(parseFloat(mapParams.center.split(\",\")[0]), parseFloat(mapParams.center.split(\",\")[1]));");
		js.append(System.getProperty("line.separator"));
		js.append("GisObject.map.setCenter(newCenter, parseInt(mapParams.zoom));");
		js.append(System.getProperty("line.separator"));
		js.append("}");
		js.append(System.getProperty("line.separator"));
		js.append(System.getProperty("line.separator"));
		js.append("function addLayers(o){");
		js.append(System.getProperty("line.separator"));
		js.append("var layer = {");
		js.append(System.getProperty("line.separator"));
		js.append("\"defaultShow\": \"1\",");
		js.append(System.getProperty("line.separator"));
		js.append("\"layer_table\": \"hk_base\",");
		js.append(System.getProperty("line.separator"));
		js.append("\"name\": \"海口电子地图(新)\", ");
		js.append(System.getProperty("line.separator"));
		js.append("\"origin\": \"461339.4642,2239097.1643\", ");
		js.append(System.getProperty("line.separator"));
		js.append("\"suffix\": \"png\",");
		js.append(System.getProperty("line.separator"));
		js.append("\"tileSize\": \"512\",");
		js.append(System.getProperty("line.separator"));
		js.append("\"tile_url\": \"http://192.168.11.236:8080/engine5/map\"");
		js.append(System.getProperty("line.separator"));
		js.append("}");
		js.append(System.getProperty("line.separator"));
		js.append("var layer = o.getASTLayer(layer);");
		js.append(System.getProperty("line.separator"));
		js.append("if(o.map)");
		js.append(System.getProperty("line.separator"));
		js.append("o.map.addLayer(layer);");
		js.append(System.getProperty("line.separator"));
		js.append("}");
		js.append(System.getProperty("line.separator"));
		js.append("</script>");
		
		strArr[1]=js.toString();
		
		StringBuffer tagHtml=new StringBuffer();
		
		tagHtml.append("<div id=\""+tagElement.getId()+"\"");
		tagHtml.append(System.getProperty("line.separator"));
		tagHtml.append("style=\"position: absolute; left: 0px; top: 0px; width: "+tagElement.getName1()+"; height: "+tagElement.getName2()+"; z-index: 10\">");
		tagHtml.append(System.getProperty("line.separator"));
		tagHtml.append("</div>");
		
		strArr[2]=tagHtml.toString();
		
		return strArr;
	}

}
